<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <div>n为{{n}}</div>
        <div>数字:{{num}}</div>
        <div>姓名 {{username}}</div>
    </div>
</body>
<script>

    function  Vue(options){//option是一个对象

        //找到目标渲染范围
        this.target  = document.querySelector(options.el);
        //找到目标渲染范围中用到了data中的哪些数据 然后完成替换
        let  html  = this.target.innerHTML;
        let  data  = options.data;//数据

        Object.keys(data).forEach(attr=>{
            html = html.replace(`{{${attr}}}`,data[attr]);
        })
        this.target.innerHTML  = html;



    

    }
    new Vue({
        el:"#app",
        data:{
            n:1,
            num:999,
            username:"leson"
        }

    })

</script>
</html>